package strategy_pattern.v3;

/**
 * 优惠枚举类
 */
public enum BenefitEnum {
    NormalBenefit(0),
    EightDiscountRebateBenefit(1),
    SevenDiscountRebateBenefit(2),
    HalfDiscountRebateBenefit(3),
    EveryThreeRetOneHundredDBenefit(4);

    private int benefitCode;

    BenefitEnum(int benefitCode) {
        this.benefitCode = benefitCode;
    }

    public int getBenefitCode() {
        return benefitCode;
    }

    public void setBenefitCode(int benefitCode) {
        this.benefitCode = benefitCode;
    }

    public static BenefitEnum getEnumByType(String code) {
        BenefitEnum benefitEnum = null;
        switch (code) {
            case "0":
                benefitEnum = NormalBenefit;
                break;
            case "1":
                benefitEnum = EightDiscountRebateBenefit;
                break;
            case "2":
                benefitEnum = SevenDiscountRebateBenefit;
                break;
            case "3":
                benefitEnum = HalfDiscountRebateBenefit;
                break;
            case "4":
                benefitEnum = EveryThreeRetOneHundredDBenefit;
                break;
        }
        return benefitEnum;
    }
}
